package com.dotc.patterndemo.create.builder;

import com.dotc.patterndemo.entity.Fruitt.Apple;
import com.dotc.patterndemo.entity.Fruitt.Banana;
import com.dotc.patterndemo.entity.Fruitt.Orange;

public class HolidayBuilder implements Builder{
    private FruitMeal fruitMeal = new FruitMeal();
    @Override
    public void buildApple(int price) {
        Apple apple = new Apple();
        apple.setPrice(price);
        fruitMeal.setApple(apple);
    }

    @Override
    public void buildBanana(int price) {
        Banana banana = new Banana();
        banana.setPrice(price);
        fruitMeal.setBanana(banana);

    }

    @Override
    public void buildOrange(int price) {
        Orange fruit = new Orange("Peter",80);
        fruit.setPrice(price);
        fruitMeal.setOrange(fruit);
    }

    @Override
    public FruitMeal getFruitMeal() {
        fruitMeal.setDiscount(15);//折扣价格对一个套餐来，是固定的
        fruitMeal.init();
        return fruitMeal;
    }
}
